package com.example.zoom001.util;

import android. content. Context;
import android. util. DisplayMetrics;
import android. view. WindowManager;

public class Displayutil {

    public static class DisplayUtil {
        //获取屏幕宽度
        public static int getScreenWidth(Context ctx) {
            WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
            DisplayMetrics dm = new DisplayMetrics();
            wm.getDefaultDisplay().getMetrics(dm);
            return dm.widthPixels;
        }

        //获取屏幕高度
        public static int getScreenHeigth(Context ctx) {
            WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
            DisplayMetrics dm = new DisplayMetrics();
            wm.getDefaultDisplay().getMetrics(dm);
            return dm.heightPixels;
        }

        //获取像素密度
        public static float getScreenDensity(Context ctx) {
            WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
            DisplayMetrics dm = new DisplayMetrics();
            wm.getDefaultDisplay().getMetrics(dm);
            return dm.density;
        }
    }

}
